﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Diagnostics.Contracts;

namespace DataStructure.Interview
{
    public class Question6
    {
        public static void EncodeSpace(int[][] matrix)
        {
            BitArray row = new BitArray(matrix.GetUpperBound(0));
            BitArray col = new BitArray(matrix.GetUpperBound(0));

            for (int i = 0; i < matrix.GetUpperBound(0); i++)
            {
                for (int j = 0; j < matrix.GetUpperBound(1); j++)
                {
                    if (matrix[i][j] == 0)
                    {
                        row[i] = true;
                        col[j] = true;
                    }
                    else if (row[i] || col[j])
                    {
                        matrix[i][j] = 0;
                    }
                }
            }
        }

    }
}
